package com.bkhc.business.entity;

import com.bkhc.common.annotation.Uid;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 业务组群
 */
@Entity
@Data
@Table(name = "tbl_business_group")
@EntityListeners(AuditingEntityListener.class)
public class Group implements Serializable {

    @GeneratedValue(strategy = GenerationType.AUTO)
    @Id
    private Integer id ;
    @Uid
    @Column(name = "group_code")
    private String groupCode;

    @Column(name = "group_name")
    private String groupName;

    @Column(name = "manager")  //memberId
    private String manager;

    @OneToMany(targetEntity = Member.class)
    @JoinColumn(name = "group_code",referencedColumnName = "group_code")
    private List<Member> members;

    @Column(name = "creator",updatable = false)
    private String creator;

    @Column(name = "create_date",updatable = false)
    @CreatedDate
    private Date createDate;

    @Column(name = "updator")
    private String updator;

    @LastModifiedDate
    @Column(name = "update_date")
    private Date updateDate;

    @Column(name = "product_codes")
    private String productCodes;

}
